//
//  ZhuXiaoViewController.m
//  TQY
//
//  Created by 甘世清 on 2024/8/23.
//

#import "ZhuXiaoViewController.h"
#import "LoginViewController.h"
@interface ZhuXiaoViewController ()
@property (nonatomic , strong)SQCustomButton * rightBtn;
@end

@implementation ZhuXiaoViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.zx_navTitle = SQNSLocalString(@"注销");
    // Do any additional setup after loading the view.
}

- (void)SQ_UIViewForSelfView{
    UILabel * label = [[UILabel alloc]init];
    label.text = SQNSLocalString(@"尊敬的用户，您即将进行账号注销操作。\n \n此操作不可逆，请您谨慎考虑。\n \n注销后，您的个人数据将被清除且无法恢复。\n \n如您确定注销，请点击 “确认注销”。\n \n感谢您的使用与支持。");
    label.numberOfLines = 0;
    label.font = FONT_MEDIUM(16);
    label.textColor = UIColor.blackColor;
    [self.view addSubview:label];
    [label mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self.view);
            make.width.mas_equalTo(SCREEN_WIDETH-48);
            make.top.equalTo(self.zx_navBar.mas_bottom).offset(20);
    }];
    
    [self.view addSubview:self.rightBtn];
    [self.rightBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.view.mas_bottom).offset(-FootHeight-40);
        make.height.mas_equalTo(54);
        make.centerX.equalTo(self.view);
        make.width.mas_equalTo(SCREEN_WIDETH - 60);
    }];
    WS(weakSelf);
    [LSTTimer addTimerForTime:11 identifier:@"" handle:^(NSString * _Nonnull day, NSString * _Nonnull hour, NSString * _Nonnull minute, NSString * _Nonnull second, NSString * _Nonnull ms) {
        weakSelf.rightBtn.text = [NSString stringWithFormat:@"%@(%@s)",SQNSLocalString(@"确认注销"),second];
    } finish:^(NSString * _Nonnull identifier) {
        weakSelf.rightBtn.text =  SQNSLocalString(@"确认注销");
        weakSelf.rightBtn.backgroundColor = SQColor(@"#FF3B30");
        weakSelf.rightBtn.textColor = SQColor(@"#FFFFFF");
        weakSelf.rightBtn.SQTouchBtn.enabled = YES;
    } pause:^(NSString * _Nonnull identifier) {
        
    }];
    [self.rightBtn setTouchBlock:^(SQCustomButton * _Nonnull button) {
        [weakSelf SQ_querenzhuxiao];
    }];
}

-(void)SQ_querenzhuxiao{
    [YJProgressHUD SQ_showMsgWithoutView:@""];
    [HttpTool post:@"user/logoff" paramDic:[NSMutableDictionary new] successBlock:^(BaseModel * _Nonnull httpModel) {
        [Manager SQ_removeObjectForKey:@"account"];
        [UserModel clearLocalUserModel];
        UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:[[LoginViewController alloc]init]];
         self.view.window.rootViewController = nav;
        } andFailBloc:^(BaseModel * _Nonnull httpModel, NSError * _Nullable error) {
            [YJProgressHUD showMsgWithoutView:httpModel.message];
    }];
   
}

- (SQCustomButton *)rightBtn{
    if (!_rightBtn) {
        _rightBtn = [[SQCustomButton alloc]initType:SQCustomButtonTopImageType imageSize:CGSizeMake(0, 0) midmargin:0];
        _rightBtn.text = SQNSLocalString(@"确认注销");
        _rightBtn.textColor = SQColor999999;
        _rightBtn.font = FONT_REGULAR(16);
        _rightBtn.backgroundColor = SQColor(@"#D8D8D8");
        _rightBtn.SQTouchBtn.enabled = NO;
        _rightBtn.layer.cornerRadius = 10;
    }
    return _rightBtn;
}

@end
